package com.tiyende.credit.loop.utils.shared

/**
 * SharedHelper
 * @Author wwdeng
 * @CreateTime: 2024/11/8 10:59
 * @Annotation：SharedPreferences 数据存取帮助类
 */
object TiyendeSharedHelper {

    /**
     * 保存数据
     */
    fun addTiyendeSharedData(key: String, value: Any){
        SharedPreferencesUtils.put(key,value)
    }

    /**
     * 获取String
     */
    fun queryTiyendeSharedString(key: String): String{
        return SharedPreferencesUtils.getString(key)
    }

    /**
     * 获取boolean
     */
    fun queryTiyendeSharedBoolean(key: String): Boolean{
        return SharedPreferencesUtils.getBoolean(key,false)
    }

    /**
     * 获取Int
     */
    fun queryTiyendeSharedInt(key: String): Int{
        return SharedPreferencesUtils.getInt(key,0)
    }


    /**
     * 移除指定内容
     */
    fun deleteTiyendeSharedData(key: String){
        SharedPreferencesUtils.remove(key)
    }

    /**
     * 退出登录，移除用户信息
     */
    fun onTiyendeLoginOut(){
        //移除已登录状态
        deleteTiyendeSharedData(TiyendeSharedKey.TIYENDE_LOGIN)
        //移除用户Token
        deleteTiyendeSharedData(TiyendeSharedKey.TIYENDE_TOKEN)
        //移除用户id
        deleteTiyendeSharedData(TiyendeSharedKey.TIYENDE_USERID)
        deleteTiyendeSharedData(TiyendeSharedKey.TIYENDE_MOBILE)
        deleteTiyendeSharedData(TiyendeSharedKey.TIYENDE_IS_ADSOURCE)
//        deleteTiyendeSharedData(TiyendeSharedKey.TIYENDE_PROCESS)
        deleteTiyendeSharedData(TiyendeSharedKey.TIYENDE_CUSTOM_DATA)
        deleteTiyendeSharedData(TiyendeSharedKey.TIYENDE_PERMISSION_PAGE_STATUS)
    }
}